/**
 * 
 */
package game;

/**
 * @author Jean-Baptiste BORIC
 *
 */
public class WeaponType {
	private String name;
	private int minRange;
	private int maxRange;
	private int ammo;
	
	/**
	 * @param name
	 * @param minRange
	 * @param maxRange
	 * @param ammo
	 */
	public WeaponType(String name, int minRange, int maxRange, int ammo) {
		super();
		
		// Bootstrap min and max range to prevent min > max problem in setters
		this.minRange = minRange;
		this.maxRange = maxRange;
		
		this.setName(name);
		this.setMinRange(minRange);
		this.setMaxRange(maxRange);
		this.setAmmo(ammo);
	}

	/**
	 * @return Name of weapon
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * @param name Name of weapon
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * @return Minimum range of weapon
	 */
	public int getMinRange() {
		return minRange;
	}
	
	/**
	 * @param minRange Minimum range of weapon
	 */
	public void setMinRange(int minRange) {
		if(minRange < 1 || minRange > this.getMaxRange() || maxRange > 99) {
			throw new IllegalArgumentException("Min range invalid");
		}
		this.minRange = minRange;
	}
	
	/**
	 * @return Maximum range of weapon
	 */
	public int getMaxRange() {
		return maxRange;
	}
	
	/**
	 * @param maxRange Maximum range of weapon
	 */
	public void setMaxRange(int maxRange) {
		if(maxRange < 1 || maxRange < this.getMinRange() || maxRange > 99) {
			throw new IllegalArgumentException("Max range invalid");
		}
		this.maxRange = maxRange;
	}
	
	/**
	 * @return Ammo capacity
	 */
	public int getAmmo() {
		return ammo;
	}
	
	/**
	 * @param ammo Ammo capacity
	 */
	public void setAmmo(int ammo) {
		if(ammo < 0 || ammo > 100) {
			throw new IllegalArgumentException("Ammo not between 0 and 99");
		}
		this.ammo = ammo;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return name + "\t" + minRange + "\t" + maxRange + "\t" + ammo;
	}	
}
